package kr.saeildamil.androidstudy.ch07;

import kr.saeildamil.androidstudy.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;

public class DrawBitmapEx extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		DrawView dv = new DrawView(this);
		setContentView(dv);
	}
}

class DrawView extends View {
	Bitmap btm;

	public DrawView(Context context) {
		super(context);
		btm = BitmapFactory.decodeResource(getResources(), R.drawable.harubang);
	}

	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		canvas.drawBitmap(btm, 10, 10, null); //원본이미지를  (10,10)좌표에 드로우
		canvas.drawBitmap(btm, null, new Rect(120, 10, 170, 85), null); //이미지를 축소  new Rect();에 의해
		canvas.drawBitmap(btm, new Rect(30, 30, 70, 80), new Rect(180, 10, 180+80, 10+100), null);
		canvas.drawBitmap(btm, null, new Rect(10, 200, 380, 400), null);
	}
}